<template>
  <div class="easyd-weixin-Box">
     <div class="agentInfomationLogBox">
         <img src="static/images/haoxiaozhang.jpg" />
     </div>
     <div class="agentInfomationTitleBox"></div>
     <div class="agentInfomationInputBox">
         <div class="agentInfomationInputItem">
             <input type="text" v-model="userName" placeholder="请输入账号" />
         </div>
         <div class="agentInfomationInputItem">
             <input type="password" v-model="userPassword" placeholder="请输入密码" />
         </div>
     </div>
     <div class="agentInfomationInputSubmitBox">
         <div class="agentInfomationInputSubmit" @click="submitBtn">登录</div>
     </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
    data(){
        return {
            userName : '',
            userPassword : '',
        }
    },
    computed: {
        ...mapState({
//          addSellForm  : state => state.UserModule.sellAddData
      			tabMenuData              : state => state.AppModule.tabMenuData,
      			tabMenuData1              : state => state.AppModule.tabMenuData1,
      			tabMenuData2              : state => state.AppModule.tabMenuData2,

        })
    },
    mounted(){
    },
    methods : {
    		...mapMutations(["AppModule/updateTabNumber"]),
        submitBtn(){

            if(this.$common.vEmpty(this.userName)){
                this.$easyUtil.errorToast(this,'账号不能为空');  
                return; 
            }

            if(this.$common.vEmpty(this.userPassword)){
                this.$easyUtil.errorToast(this,'密码不能为空');  
                return; 
            }

            var params = {
                username  : this.userName,
                password  : this.userPassword,
            }
            
            var that = this;

           this.$easyUtil.startLoading(this)
           this.$http.postHttp(this.$API.login,params,(rs)=>{

                this.$easyUtil.endLoading(this)
                this.$easyUtil.successToast(this, '登录成功');
                
                localStorage.setItem('u_phone',that.userName);
                localStorage.setItem('u_id',rs.u_id);
                localStorage.setItem('u_master_osid',rs.u_master_osid);
                localStorage.setItem('u_type',rs.u_type);
                localStorage.setItem('u_nickname',rs.u_nickname);
                localStorage.setItem('u_master_name',rs.u_master_name);
                localStorage.setItem('u_is_manager',rs.u_is_manager);
                localStorage.setItem('u_leader',rs.u_leader);
//              
//              var newArr = [];
//              if(rs.u_is_manager == 0 || rs.u_type == 2){
//						      //更新底部tab
//						      this["AppModule/updateTabNumber"](this.tabMenuData2);
//              }else{
//              	//更新底部tab
//              	this["AppModule/updateTabNumber"](this.tabMenuData1);
//              }
//              
//              this.$easyUtil.tabSelectedGoPage(this,0)
								location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + this.$global.WEIXIN_APP_ID + "&redirect_uri=http%3a%2f%2f" + this.$global.SERVER_IP + "%2fCRM%2f%23%2fweixinlogin&response_type=code&scope=snsapi_base&state=linshiputongXXX" + rs.u_id + "#wechat_redirect";
								return;

            })
            
        }
    }
}
</script>

<style lang="stylus" scoped>
@import '~PUBLIC_CSS'
.agentInfomationLogBox {
    width 100%
    height 150px
    text-align center
    margin-top 80px

    img {
        width 150px
        height 150px
        border-radius 5px

    }
}

.agentInfomationTitleBox {
    width 100%
    height 40px
    text-align center
    margin-top 30px
    font-weight 500
    color #666
    letter-spacing 2px
}

.agentInfomationInputBox {
    width 100%
    height auto
    margin-top 10px
    padding-left 15px
    padding-right 15px
    box-sizing border-box

    .agentInfomationInputItem {
        width 100%
        height 45px;
        background #fff
        border-radius 5px    
        margin-bottom 15px
        overflow hidden
        position relative
        border 1px solid #eee

        input {
            width 100%
            height 100%
            padding 15px
            overflow hidden
            border none
            -webkit-appearance: none;
            box-sizing border-box
            outline none
        }
    }
}

.agentInfomationInputSubmitBox {
    width 100%
    height 45px
    padding-left 15px
    box-sizing border-box
    padding-right 15px
    margin-top 30px

    .agentInfomationInputSubmit {
        width 100%
        height 45px
        text-align center
        line-height 45px
        border 1px solid #f0f0f0
        border-radius 5px
        color #fff
        letter-spacing 2px
        background: #FAD236
    }
}

.agentInfomationBottom {
    position absolute
    bottom 0px
    width 100%
    text-align center
    height 40px
    line-height 40px
    font-size 12px
    color #fff
}
</style>